*******************************
* IRCA and Redistricting
* Navid Sabet and Noam Yuchtman
* Figure 7: State level IRCA and distribution of district compactness
*******************************

	//Load data
	use  state_irca_districts.dta, clear

	
	//Drop Single District States in 1990
	drop if single_district1990==1 


***************************************************************
* PP Scores
***************************************************************
	//Dem Low, Pre Post
	twoway (hist pp if state_irca_above_med==0 & congress==102 & legal_control_kaplan1991==1,  xtitle("") percent bin(25) lcolor(blue) fcolor(none)) ///
			(hist pp if state_irca_above_med==0 & congress==103 & legal_control_kaplan1991==1,  xtitle("") percent bin(25) lcolor(blue) fcolor(blue%50)), ///
			legend(order(1 "102 Congress" 2 "103 Congress") pos(6) col(2)) title(Low IRCA States Dem Control, size(small)) ylab(, nogrid)
			graph save dem_low_pre_post.gph, replace
	
	//Dem High, Pre Post	
	twoway (hist pp if state_irca_above_med==1 & congress==102 & legal_control_kaplan1991==1,  xtitle("") percent bin(25) lcolor(blue) fcolor(none)) ///
			(hist pp if state_irca_above_med==1 & congress==103 & legal_control_kaplan1991==1, xtitle("") percent bin(25) lcolor(blue) fcolor(blue%50)), ///
			legend(order(1 "102 Congress" 2 "103 Congress") pos(6) col(2)) title(High IRCA States Dem Control, size(small)) ylab(, nogrid)
			graph save dem_high_pre_post.gph, replace
			
		//Non-Dem Low, Pre Post
	twoway (hist pp if state_irca_above_med==0 & congress==102 & legal_control_kaplan1991!=1,  xtitle("") percent bin(25) lcolor(red) fcolor(none)) ///
			(hist pp if state_irca_above_med==0 & congress==103 & legal_control_kaplan1991!=1,  xtitle("") percent bin(25) lcolor(red) fcolor(red%50)), ///
			legend(order(1 "102 Congress" 2 "103 Congress") pos(6) col(2)) title(Low IRCA States Non-Democratic Control, size(small)) ylab(, nogrid)
			graph save rep_low_pre_post.gph, replace
	
	//Non-Dem High, Pre Post	
	twoway (hist pp if state_irca_above_med==1 & congress==102 & legal_control_kaplan1991!=1,  xtitle("") percent bin(25) lcolor(red) fcolor(none)) ///
			(hist pp if state_irca_above_med==1 & congress==103 & legal_control_kaplan1991!=1,  xtitle("") percent bin(25) lcolor(red) fcolor(red%50)), ///
			legend(order(1 "102 Congress" 2 "103 Congress") pos(6) col(2)) title(High IRCA States Non-Democratic Control, size(small)) ylab(, nogrid)
			graph save rep_high_pre_post.gph, replace
			
			

***************************************************************
* Reock Scores
***************************************************************
	//Dem Low, Pre Post
	twoway (hist reock if state_irca_above_med==0 & congress==102 & legal_control_kaplan1991==1,  xtitle("") percent bin(25) lcolor(blue) fcolor(none)) ///
			(hist reock if state_irca_above_med==0 & congress==103 & legal_control_kaplan1991==1,  xtitle("") percent bin(25) lcolor(blue) fcolor(blue%50)), ///
			legend(order(1 "102 Congress" 2 "103 Congress") pos(6) col(2)) title(Low IRCA States Dem Control, size(small)) ylab(, nogrid)
			graph save dem_low_pre_post_reock.gph, replace
	
	//Dem High, Pre Post	
	twoway (hist reock if state_irca_above_med==1 & congress==102 & legal_control_kaplan1991==1,  xtitle("") percent bin(25) lcolor(blue) fcolor(none)) ///
			(hist reock if state_irca_above_med==1 & congress==103 & legal_control_kaplan1991==1, xtitle("") percent bin(25) lcolor(blue) fcolor(blue%50)), ///
			legend(order(1 "102 Congress" 2 "103 Congress") pos(6) col(2)) title(High IRCA States Dem Control, size(small)) ylab(, nogrid)
			graph save dem_high_pre_post_reock.gph, replace
			
		//Non-Dem Low, Pre Post
	twoway (hist reock if state_irca_above_med==0 & congress==102 & legal_control_kaplan1991!=1,  xtitle("") percent bin(25) lcolor(red) fcolor(none)) ///
			(hist reock if state_irca_above_med==0 & congress==103 & legal_control_kaplan1991!=1,  xtitle("") percent bin(25) lcolor(red) fcolor(red%50)), ///
			legend(order(1 "102 Congress" 2 "103 Congress") pos(6) col(2)) title(Low IRCA States Non-Democratic Control, size(small)) ylab(, nogrid)
			graph save rep_low_pre_post_reock.gph, replace
	
	//Non-Dem High, Pre Post	
	twoway (hist reock if state_irca_above_med==1 & congress==102 & legal_control_kaplan1991!=1,  xtitle("") percent bin(25) lcolor(red) fcolor(none)) ///
			(hist reock if state_irca_above_med==1 & congress==103 & legal_control_kaplan1991!=1,  xtitle("") percent bin(25) lcolor(red) fcolor(red%50)), ///
			legend(order(1 "102 Congress" 2 "103 Congress") pos(6) col(2)) title(High IRCA States Non-Democratic Control, size(small)) ylab(, nogrid)
			graph save rep_high_pre_post_reock.gph, replace
					
		
*********
* Save (grc1leg2 allows a common legend.)
*********

		
//Combine PP results
	grc1leg2  dem_low_pre_post.gph  dem_high_pre_post.gph  rep_low_pre_post.gph  rep_high_pre_post.gph, col(2) xcommon ycommon title(" ") legendfrom()
		
		graph save $output/fig7a.gph, replace 
		graph export $output/fig7a.pdf, replace 
		
		
		
//Combine Reock results
	grc1leg2  dem_low_pre_post_reock.gph  dem_high_pre_post_reock.gph rep_low_pre_post_reock.gph rep_high_pre_post_reock.gph, col(2) xcommon ycommon title(" ") legendfrom()
		
		graph save fig7b.gph, replace 
		graph export fig7b.pdf, replace 
		
		

				
				
			
